<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>查看预订信息</title>
</head>
<body>
<h2>预订列表</h2>
<%
    // 数据库连接信息
    String jdbcUrl = "jdbc:mariadb://10.220.140.102:3366/studb11";
    String jdbcUsername = "stua";
    String jdbcPassword = "zHZUA65r";

       
        Connection conn = DriverManager.getConnection(jdbcUrl, jdbcUsername, jdbcPassword);

        
        int hotelId = 1;

        String sql = "SELECT * FROM bookings WHERE hotel_id = ?";
        PreparedStatement statement = conn.prepareStatement(sql);
        statement.setInt(1, hotelId);

        ResultSet rs = statement.executeQuery("select*from hotel");

        // 显示预订信息
        while (rs.next()) {
            int id = rs.getInt("id");
            int userId = rs.getInt("user_id");
            Date bookingDate = rs.getDate("booking_date");
            String status = rs.getString("status");
            out.println("<p>预订ID: " + id + " - 用户ID: " + userId + " - 预订日期: " + bookingDate + " - 状态: " + status + "</p >");
        }

        rs.close();
        statement.close();
        conn.close();
 
%>
</body>
</html>